        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>ContactListener interface / box2d_html Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d_html" data-type="ContactListener">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d_html.html">box2d_html</a> &rsaquo; <a href="../box2d_html/ContactListener.html">ContactListener</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>ContactListener</strong>
          interface
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<p>Implement this interface to get contact information. You can use these
results for things like sounds and game logic. You can also get contact
results by traversing the contact lists after the time step. However, you
might miss some contacts because continuous physics leads to sub-stepping.
Additionally you may receive multiple callbacks for the same contact in a
single time step.
You should strive to make your callbacks efficient because there may be
many callbacks per time step.</p>
<p>warning: You cannot create/destroy Box2D entities inside these callbacks.</p>
<pre class="source">
interface ContactListener {
  /**
   * Called when two fixtures begin to touch.
   */
  void beginContact(Contact contact);

  /**
   * Called when two fixtures cease to touch.
   */
  void endContact(Contact contact);

  /**
   * This is called after a contact is updated. This allows you to inspect a
   * contact before it goes to the solver. If you are careful, you can modify 
   * the contact manifold (e.g. disable contact).
   * A copy of the old manifold is provided so that you can detect changes.
   * Note: this is called only for awake bodies.
   * Note: this is called even when the number of contact points is zero.
   * Note: this is not called for sensors.
   * Note: if you set the number of contact points to zero, you will not
   * get an EndContact callback. However, you may get a BeginContact callback
   * the next step.
   * Note: the oldManifold parameter is pooled, so it will be the same object
   * for every callback for each thread.
   */
  void preSolve(Contact contact, Manifold oldManifold);

  /**
   * This lets you inspect a contact after the solver is finished. This is
   * useful for inspecting impulses.
   * Note: the contact manifold does not include time of impact impulses,
   * which can be arbitrarily large if the sub-step is small. Hence the impulse
   * is provided explicitly in a separate data structure.
   * Note: this is only called for contacts that are touching, solid, and awake.
   */
   void postSolve(Contact contact, ContactImpulse impulse);
}
</pre>
</div>
<div>
<h3>Properties</h3>
<div class="field inherited"><h4 id="runtimeType">
<button class="show-code">Code</button>
final Type         <strong>runtimeType</strong> <a class="anchor-link"
            href="#runtimeType"
            title="Permalink to ContactListener.runtimeType">#</a>
        </h4>
        <div class="inherited-from">inherited from Object </div><div class="doc">
<p>A representation of the runtime type of the object.</p>
<pre class="source">
external Type get runtimeType;
</pre>
</div>
</div>
</div>
<div>
<h3>Operators</h3>
<div class="method inherited"><h4 id="==">
<button class="show-code">Code</button>
bool <strong>operator ==</strong>(other) <a class="anchor-link" href="#=="
              title="Permalink to ContactListener.operator ==">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>The equality operator.</p>
<p>The default behavior for all <code>Object</code>s is to return true if and
only if <code>this</code> and 
<span class="param">other</span> are the same object.</p>
<p>If a subclass overrides the equality operator it should override
the <code>hashCode</code> method as well to maintain consistency.</p>
<pre class="source">
bool operator ==(other) =&gt; identical(this, other);
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="beginContact">
<button class="show-code">Code</button>
void <strong>beginContact</strong>(<a href="../box2d_html/Contact.html">Contact</a> contact) <a class="anchor-link" href="#beginContact"
              title="Permalink to ContactListener.beginContact">#</a></h4>
<div class="doc">
<p>Called when two fixtures begin to touch.</p>
<pre class="source">
void beginContact(Contact contact);
</pre>
</div>
</div>
<div class="method"><h4 id="endContact">
<button class="show-code">Code</button>
void <strong>endContact</strong>(<a href="../box2d_html/Contact.html">Contact</a> contact) <a class="anchor-link" href="#endContact"
              title="Permalink to ContactListener.endContact">#</a></h4>
<div class="doc">
<p>Called when two fixtures cease to touch.</p>
<pre class="source">
void endContact(Contact contact);
</pre>
</div>
</div>
<div class="method inherited"><h4 id="hashCode">
<button class="show-code">Code</button>
int <strong>hashCode</strong>() <a class="anchor-link" href="#hashCode"
              title="Permalink to ContactListener.hashCode">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Get a hash code for this object.</p>
<p>All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator <code>==</code>. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.</p>
<p>If a subclass overrides <code>hashCode</code> it should override the
equality operator as well to maintain consistency.</p>
<pre class="source">
external int hashCode();
</pre>
</div>
</div>
<div class="method inherited"><h4 id="noSuchMethod">
<button class="show-code">Code</button>
<strong>noSuchMethod</strong>(String name, List args) <a class="anchor-link" href="#noSuchMethod"
              title="Permalink to ContactListener.noSuchMethod">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p><code>noSuchMethod</code> is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to <code>noSuchMethod</code>. If <code>noSuchMethod</code>
returns a value, that value becomes the result of the original
invocation.</p>
<p>The default behavior of <code>noSuchMethod</code> is to throw a
<code>noSuchMethodError</code>.</p>
<pre class="source">
external Dynamic noSuchMethod(String name, List args);
</pre>
</div>
</div>
<div class="method inherited"><h4 id="Object">
<button class="show-code">Code</button>
const <strong>Object</strong>() <a class="anchor-link" href="#Object"
              title="Permalink to ContactListener.Object">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Creates a new <code>Object</code> instance.</p>
<p><code>Object</code> instances have no meaningful state, and are only useful
through their identity. An <code>Object</code> instance is equal to itself
only.</p>
<pre class="source">
const Object();
</pre>
</div>
</div>
<div class="method"><h4 id="postSolve">
<button class="show-code">Code</button>
void <strong>postSolve</strong>(<a href="../box2d_html/Contact.html">Contact</a> contact, <a href="../box2d_html/ContactImpulse.html">ContactImpulse</a> impulse) <a class="anchor-link" href="#postSolve"
              title="Permalink to ContactListener.postSolve">#</a></h4>
<div class="doc">
<p>This lets you inspect a contact after the solver is finished. This is
useful for inspecting impulses.
Note: the contact manifold does not include time of impact impulses,
which can be arbitrarily large if the sub-step is small. Hence the impulse
is provided explicitly in a separate data structure.
Note: this is only called for contacts that are touching, solid, and awake.</p>
<pre class="source">
void postSolve(Contact contact, ContactImpulse impulse);
</pre>
</div>
</div>
<div class="method"><h4 id="preSolve">
<button class="show-code">Code</button>
void <strong>preSolve</strong>(<a href="../box2d_html/Contact.html">Contact</a> contact, <a href="../box2d_html/Manifold.html">Manifold</a> oldManifold) <a class="anchor-link" href="#preSolve"
              title="Permalink to ContactListener.preSolve">#</a></h4>
<div class="doc">
<p>This is called after a contact is updated. This allows you to inspect a
contact before it goes to the solver. If you are careful, you can modify
the contact manifold (e.g. disable contact).
A copy of the old manifold is provided so that you can detect changes.
Note: this is called only for awake bodies.
Note: this is called even when the number of contact points is zero.
Note: this is not called for sensors.
Note: if you set the number of contact points to zero, you will not
get an EndContact callback. However, you may get a BeginContact callback
the next step.
Note: the oldManifold parameter is pooled, so it will be the same object
for every callback for each thread.</p>
<pre class="source">
void preSolve(Contact contact, Manifold oldManifold);
</pre>
</div>
</div>
<div class="method inherited"><h4 id="toString">
<button class="show-code">Code</button>
String <strong>toString</strong>() <a class="anchor-link" href="#toString"
              title="Permalink to ContactListener.toString">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Returns a string representation of this object.</p>
<pre class="source">
external String toString();
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
